




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MaSystemParamManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MaSystemParamManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MaSystemParamManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MaSystemParam";
        }
		
		public MaSystemParamEntity Insert(MaSystemParamEntity _MaSystemParamEntity)
		{
			return Insert(_MaSystemParamEntity, "");
		}
		
		public MaSystemParamEntity Insert(MaSystemParamEntity _MaSystemParamEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MaSystemParamEntity, true);
				MaSystemParamFields field = new MaSystemParamFields();
                LogEntity(_MaSystemParamEntity, field, AcInsert, controlId);
			}
			return _MaSystemParamEntity;
		}

		
		public MaSystemParamEntity Insert(Guid Id, string ParamName, string ParamValue, string Description, bool IsEnabled, string Category, int OrderIndex, Guid BranchId, Guid DepartId, string Region)
		{
			MaSystemParamEntity _MaSystemParamEntity = new MaSystemParamEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaSystemParamEntity.Id = Id;
				_MaSystemParamEntity.ParamName = ParamName;
				_MaSystemParamEntity.ParamValue = ParamValue;
				_MaSystemParamEntity.Description = Description;
				_MaSystemParamEntity.IsEnabled = IsEnabled;
				_MaSystemParamEntity.Category = Category;
				_MaSystemParamEntity.OrderIndex = OrderIndex;
				_MaSystemParamEntity.BranchId = BranchId;
				_MaSystemParamEntity.DepartId = DepartId;
				_MaSystemParamEntity.Region = Region;
				MaSystemParamFields field = new MaSystemParamFields();
                LogEntity(_MaSystemParamEntity, field, AcInsert);
				adapter.SaveEntity(_MaSystemParamEntity, true);
			}
			return _MaSystemParamEntity;
		}

		public MaSystemParamEntity Insert(string ParamName, string ParamValue, string Description, bool IsEnabled, string Category, int OrderIndex, Guid BranchId, Guid DepartId, string Region)
		{
			MaSystemParamEntity _MaSystemParamEntity = new MaSystemParamEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaSystemParamEntity.ParamName = ParamName;
				_MaSystemParamEntity.ParamValue = ParamValue;
				_MaSystemParamEntity.Description = Description;
				_MaSystemParamEntity.IsEnabled = IsEnabled;
				_MaSystemParamEntity.Category = Category;
				_MaSystemParamEntity.OrderIndex = OrderIndex;
				_MaSystemParamEntity.BranchId = BranchId;
				_MaSystemParamEntity.DepartId = DepartId;
				_MaSystemParamEntity.Region = Region;
				adapter.SaveEntity(_MaSystemParamEntity, true);
				MaSystemParamFields field = new MaSystemParamFields();
                LogEntity(_MaSystemParamEntity, field, AcInsert);
			}
			return _MaSystemParamEntity;
		}
		
		public bool Update(MaSystemParamEntity _MaSystemParamEntity)
        {
            return Update(_MaSystemParamEntity, "");
        }

		public bool Update(MaSystemParamEntity _MaSystemParamEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MaSystemParamFields.Id == _MaSystemParamEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MaSystemParamEntity, filter);
				toReturn = true;
				
				MaSystemParamFields field = new MaSystemParamFields();
                LogEntity(_MaSystemParamEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MaSystemParamEntity _MaSystemParamEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MaSystemParamEntity, filter);
				toReturn = true;
				
				MaSystemParamFields field = new MaSystemParamFields();
                LogEntity(_MaSystemParamEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(Guid Id, string ParamName, string ParamValue, string Description, bool IsEnabled, string Category, int OrderIndex, Guid BranchId, Guid DepartId, string Region)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemParamEntity _MaSystemParamEntity = new MaSystemParamEntity(Id);
				if (adapter.FetchEntity(_MaSystemParamEntity))
				{
				
					_MaSystemParamEntity.ParamName = ParamName;
					_MaSystemParamEntity.ParamValue = ParamValue;
					_MaSystemParamEntity.Description = Description;
					_MaSystemParamEntity.IsEnabled = IsEnabled;
					_MaSystemParamEntity.Category = Category;
					_MaSystemParamEntity.OrderIndex = OrderIndex;
					_MaSystemParamEntity.BranchId = BranchId;
					_MaSystemParamEntity.DepartId = DepartId;
					_MaSystemParamEntity.Region = Region;
					adapter.SaveEntity(_MaSystemParamEntity, true);
					toReturn = true;
					
					MaSystemParamFields field = new MaSystemParamFields();
					LogEntity(_MaSystemParamEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(Guid Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemParamEntity _MaSystemParamEntity = new MaSystemParamEntity(Id);
				if (adapter.FetchEntity(_MaSystemParamEntity))
				{
					adapter.DeleteEntity(_MaSystemParamEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MaSystemParamEntity", null);
			}
		}
		
		
		public int DeleteById(Guid Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByParamName(string ParamName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamName == ParamName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByParamValue(string ParamValue)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamValue == ParamValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDescription(string Description)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnabled(bool IsEnabled)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCategory(string Category)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Category == Category);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByOrderIndex(int OrderIndex)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByBranchId(Guid BranchId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.BranchId == BranchId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDepartId(Guid DepartId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRegion(string Region)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Region == Region);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaSystemParamEntity", filter);
			}
			return toReturn;
		}
		

		
		public MaSystemParamEntity SelectOne(Guid Id)
		{
			MaSystemParamEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaSystemParamEntity _MaSystemParamEntity = new MaSystemParamEntity(Id);
				if (adapter.FetchEntity(_MaSystemParamEntity))
				{
					toReturn = _MaSystemParamEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectAllLST()
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, null, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByIdLST(Guid Id)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByIdLST_Paged(Guid Id, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(Guid Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT_Paged(Guid Id, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByParamNameLST(string ParamName)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamName == ParamName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByParamNameLST_Paged(string ParamName, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamName == ParamName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByParamNameRDT(string ParamName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamName == ParamName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByParamNameRDT_Paged(string ParamName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamName == ParamName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByParamValueLST(string ParamValue)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamValue == ParamValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByParamValueLST_Paged(string ParamValue, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamValue == ParamValue);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByParamValueRDT(string ParamValue)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamValue == ParamValue);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByParamValueRDT_Paged(string ParamValue, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.ParamValue == ParamValue);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByDescriptionLST(string Description)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByDescriptionLST_Paged(string Description, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDescriptionRDT(string Description)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDescriptionRDT_Paged(string Description, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByIsEnabledLST(bool IsEnabled)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByIsEnabledLST_Paged(bool IsEnabled, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnabledRDT(bool IsEnabled)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnabledRDT_Paged(bool IsEnabled, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.IsEnabled == IsEnabled);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByCategoryLST(string Category)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Category == Category);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByCategoryLST_Paged(string Category, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Category == Category);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCategoryRDT(string Category)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Category == Category);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCategoryRDT_Paged(string Category, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Category == Category);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByOrderIndexLST(int OrderIndex)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByOrderIndexLST_Paged(int OrderIndex, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByOrderIndexRDT(int OrderIndex)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByOrderIndexRDT_Paged(int OrderIndex, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByBranchIdLST(Guid BranchId)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.BranchId == BranchId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByBranchIdLST_Paged(Guid BranchId, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.BranchId == BranchId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByBranchIdRDT(Guid BranchId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.BranchId == BranchId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByBranchIdRDT_Paged(Guid BranchId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.BranchId == BranchId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByDepartIdLST(Guid DepartId)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByDepartIdLST_Paged(Guid DepartId, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDepartIdRDT(Guid DepartId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDepartIdRDT_Paged(Guid DepartId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.DepartId == DepartId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByRegionLST(string Region)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Region == Region);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null);
			}
			return _MaSystemParamCollection;
		}
		
		// Return EntityCollection<MaSystemParamEntity>
		public EntityCollection<MaSystemParamEntity> SelectByRegionLST_Paged(string Region, int PageNumber, int PageSize)
		{
			EntityCollection<MaSystemParamEntity> _MaSystemParamCollection = new EntityCollection<MaSystemParamEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Region == Region);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaSystemParamCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaSystemParamCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRegionRDT(string Region)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Region == Region);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRegionRDT_Paged(string Region, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaSystemParamCollection = new EntityCollection(new MaSystemParamEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaSystemParamFields.Region == Region);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaSystemParamCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
